package com.yunshang.ysmall.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yunshang.ysmall.mapper.MbAddrInfoMapper;
import com.yunshang.ysmall.mapper.OrderInfoMapper;
import com.yunshang.ysmall.mapper.OrderItemInfoMapper;
import com.yunshang.ysmall.model.MbAddrInfo;
import com.yunshang.ysmall.model.OrderInfo;
import com.yunshang.ysmall.model.OrderItemInfo;
import com.yunshang.ysmall.service.OrderService;

@Service
public class OrderServiceImpl implements OrderService {
		@Resource
		OrderInfoMapper orderInfoMapper;
		@Resource
		MbAddrInfoMapper mbAddrInfoMapper;
		@Resource
		OrderItemInfoMapper orderItemInfoMapper;

		@Override
		public OrderInfo getOrderInfo(String orderId) {
			OrderInfo order=orderInfoMapper.selectByOrderId(orderId);
			List<OrderItemInfo> orderItems=orderItemInfoMapper.getItemListByOrderId(orderId);
			order.setItemList(orderItems);
			return   order;
		}

		@Override
		public MbAddrInfo getMbAddrInfo(Integer addrId) {
			return mbAddrInfoMapper.selectById(addrId);
		}

		@Override
		public OrderInfo getOrderInfoByOrderId(String out_trade_no) {
			return orderInfoMapper.findByOrderId(out_trade_no);
		}
}
